package com.xiaozhou.utils;

import java.util.Random;


public class CaptchaGenerator {  
    private static final String CHAR_LIST = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";  
    private static final int LENGTH = 4;  
      
    public static String generateCaptcha() {  
        StringBuilder captcha = new StringBuilder();  
        Random random = new Random();  
          
        for (int i = 0; i < LENGTH; i++) {  
            int index = random.nextInt(CHAR_LIST.length());  
            char randomChar = CHAR_LIST.charAt(index);  
            captcha.append(randomChar);  
        }  
          
        return captcha.toString();  
    }  
      

}